Release 10.1A: OpenEdge Development:
Progress 4GL Handbook


Passing a temp-table by reference

Starting with OpenEdge Release 10.1A, when you pass a temp-table and the routine call is local, you can tell Progress to optimize the call by having the called routine refer to the instance of the temp-table already in the calling routine. You tell Progress to share a single instance of the temp-table by including the BY-REFERENCE keyword on the caller’s RUN statement:

RUN internal-procedure-name IN procedure-handle 
    ([ INPUT | INPUT-OUTPUT | OUTPUT ] TABLE temp-table-name BY-REFERENCE ) 

Passing the caller’s temp-table BY-REFERENCE saves all the overhead of copying the temp-table definition and data. If the call is remote, then Progress ignores the BY-REFERENCE keyword and passes the temp-table by value, as it must in that case.

You can only specify BY-REFERENCE on an internal procedure or user-defined function call, not on a RUN of an external procedure. When you pass a temp-table parameter by reference, the called routine’s temp-table definition is bound to the calling routine’s temp-table only for the duration of the call.

To pass a temp-table by reference, in the calling routine, use the BY-REFERENCE keyword in the RUN statement that defines the temp-table parameter. There is no special syntax required in the called routine. However, since the calling routine’s temp-table instance is substituted for the called routine’s temp-table, only the definition of the temp-table is required by the called routine. In other words, the same temp-table is defined in both routines but only one is actually used. If the called routine’s temp-table is not directly used to hold its own data anywhere within the routine, you can save the overhead of allocating it by including the REFERENCE-ONLY keyword on its definition:

DEFINE TEMP-TABLE temp-table-name REFERENCE-ONLY 

This keyword tells Progress to use the definition for compiler references to the table and its fields but not to instantiate it at run time. Any reference to the temp-table, except where it is passed in from another routine BY-REFERENCE, results in a runtime error.


Copyright © 2005 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095